﻿using UnityEngine;
using System.Collections;

public class GunScript : MonoBehaviour {

	public Transform bullet;

	private float fireWaitMax = 0.25f;

	private float fireWait = 0;

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		bool fired = Input.GetButton ("Fire1");

		if (fired) {
			DoFight();
		}
	
	}

	void DoFight(){
		float delta = Time.time - fireWait;
		if (delta > fireWaitMax) {
						fireWait = Time.time;
		} else {
			return;
		}

		Transform bulletNew = (Transform) Instantiate (bullet);
		bulletNew.transform.position = new Vector2 (transform.position.x + 1, transform.position.y);
	}
}
